/** 
 * Description:用户反馈管理
 * Date:2012-6-10
 * Author:Along	
*/
package com.community.shopping.service.logic;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.community.shopping.dao.UserCommentDao;
import com.community.shopping.domain.User;
import com.community.shopping.domain.UserComment;
public class UserCommentManager {
	
	public UserCommentDao userCommentDao;

	/**
	 * @param uerDao the uerDao to set
	 */
	public void setUserCommentDao(UserCommentDao userCommentDao) {
		this.userCommentDao = userCommentDao;
	}


	private SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	//用户发表反馈
	public void addComment(String userId,String content)
	{
		UserComment userComment=new UserComment();
		if(userId==null || userId.equals(""))
		{userComment.setUserId(null);}
		else
		{
		userComment.setUserId(Integer.parseInt(userId));
		}
		userComment.setContent(content);
		userComment.setCreateTime(format.format(new Date()));
		userComment.setStatus(1);
		userCommentDao.save(userComment);
	}
	
	//管理员回复
	public void updateReComment(UserComment userComment,String recontent)
	{
		userComment.setRecontent(recontent);
		userComment.setReTime(format.format(new Date()));
		userCommentDao.save(userComment);
	}
	
	//管理员回复
	public void updateReComment(String id,String recontent)
	{
		UserComment userComment=userCommentDao.getUserCommentById(id);
		userComment.setRecontent(recontent);
		userComment.setReTime(format.format(new Date()));
		userCommentDao.save(userComment);
	}
	
	//屏蔽或取消屏蔽用户反馈 status: 0屏蔽 1不屏蔽
	public void updateComment(String id,Integer status)
	{
		UserComment userComment=userCommentDao.getUserCommentById(id);
		userComment.setStatus(status);
		userCommentDao.save(userComment);
	}
	
	//删除用户反馈
	public void deleteComment(String id)
	{
		UserComment userComment=userCommentDao.getUserCommentById(id);
		userCommentDao.delete(userComment);
	}
	
	public List queryComment(String hql)
	{
		return userCommentDao.getUserComment(hql);
	}
	
	public List queryComment(String hql,Page page)
	{
		return userCommentDao.getUserComment(hql,page);	
	}

}
